//
//  QDMetroCycleTableViewCell.m
//  QDMetroClient
//
//  Created by YueWen on 2019/1/18.
//  Copyright © 2019 YueWen. All rights reserved.
//

#import "QDMetroCycleTableViewCell.h"


CGFloat QDMetroCycleTableViewCellHeight(void) {
    
    CGFloat screenWidth = UIScreen.mainScreen.ritl_width;
    CGFloat itemLineSpacing = 40;
    CGFloat leftSapce = 20;
    CGFloat itemWidth = screenWidth - leftSapce - itemLineSpacing / 2;
    CGFloat scale =  72.0 / 335;
    return (NSInteger)ceil(itemWidth * scale) + 16;
}



@implementation QDMetroCycleTableViewCell

- (void)buildView {
    
    [super buildView];
    self.contentView.backgroundColor = RITLColorFromIntRBG(100, 181, 116);
    self.cycleView.backgroundColor = RITLColorFromIntRBG(100, 181, 116);
    self.cycleView.infiniteLoop = false;
    self.cycleView.pageEnable = true;
    self.cycleView.autoScroll = false;
    self.cycleView.contentView.backgroundColor = RITLColorFromIntRBG(100, 181, 116);
    self.cycleView.imagePathsGroup = @[@"",@""];
}


- (UIEdgeInsets)cycleContentInsets {
    return UIEdgeInsetsMake(0, 20, 0, 20);
}



#pragma mark - <RITLSDCycleScrollViewDataSource>

- (UICollectionViewLayout *)cycleScollViewcustomCollectionViewLayout:(RITLSDCycleScrollView *)cycleView {

    /// 计算常量
    CGFloat screenWidth = UIScreen.mainScreen.ritl_width;
    CGFloat leftSapce = 0;
    CGFloat itemLineSpacing = CGFLOAT_MIN;
    CGFloat itemWidth = screenWidth - 40;
    CGFloat scale =  72.0 / 335;
    CGFloat itemHeight = (NSInteger)ceil(itemWidth * scale);
    
    UICollectionViewFlowLayout *flowLayout = UICollectionViewFlowLayout.new;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.sectionInset = UIEdgeInsetsMake(16, leftSapce, 0, leftSapce);
    flowLayout.minimumLineSpacing = itemLineSpacing;
    flowLayout.itemSize = CGSizeMake(itemWidth, itemHeight);
    
    return flowLayout;
}



@end
